home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 March
/
EnigmA AMIGA RUN 05 (1996)(G.R. Edizioni)(IT)[!][issue 1996-03][Skylink CD IV].iso
/
earcd
/
comm2
/
amislt14.lha
/
AmiSlate
/
SlateRexx
/
vector.rexx
< prev
Wrap
OS/2 REXX Batch file
|
1996-01-27
|
7KB
|
517 lines
/* An Arexx script for use with AmiSlate:
Wire vector graphics for AmiSlate.
Copyright (c) 1995,1996 Johan Torin (johan@artworks.apana.org.au)
Minor enhancements by Jeremy Friesner (jfriesne@ucsd.edu)
Very simple example of AmiSlates arexx capabilities. Not optimized very
much (just a sine and cosine lookup table). On my A3000 the speed is
comparable to a 386SX/40MHz running more or less the same code, through
Microsoft Quickbasic... :)
Requires RexxMathlLib.library to run, can be found on AmiNet as:
RexxMathLib1.3.lha util/rexx 13K+ARexx function library, version 1.3
To aviod flicker, due to long redraw time, this vector drawing routine
uses a special trick, ie. it redraw one line at a time. This is the reason
for the jerky look of the objects.
*/
parse arg CommandPort ActiveString
address (CommandPort)
if (length(CommandPort) == 0) then do
say ""
say "Usage: rx Vector.rexx <REXXPORTNAME>"
say " (REXXPORTNAME is usually AMISLATE)"
say ""
say "Or run from the Rexx menu within AmiSlate."
say ""
exit 0
end
options results
/* Add library if not done before */
If ~Show('L',"rexxmathlib.library") then do
If addlib('rexxmathlib.library',0,-30,0) then
nop
else do
Say "Couldn't open RexxMathlib.library!"
exit 10
end
end
EasyRequest "Vector" '"'||"Which shape do you wish to see?"||'"' "Cube|Ball"
/* Get object */
if (rc == 1) then do
call Cube
Shape = CUBE
end
else do
call Ball
Shape = BALL
end
/* Init some variables */
XPP2 = 0
YPP2 = 0
ZPP2 = 0
YPP2 = 0
XPP3 = 0
ZPP2 = 0
PE = 0
A = 0
Do I = 1 TO RealCordNum
PSX.I = 0
PSY.I = 0
PSXOld.I = 0
PSYOld.I = 0
End
if (Shape = CUBE) then Dist = 5000
else Dist = 1000
Q1 = 0
Q2 = 0
Q3 = 0
DecIn = 10
TempDecIn = -10
/* Get windowsize */
GetWindowAttrs stem winattrs.
XG = (winattrs.width - 58) / 2
YG = (winattrs.height - 53) / 2
SetWindowTitle '"' || "Setting up rotation tables... 628" || '"'
/* Setup sine & cosine tables */
do i = 0 to 628
QuickSin.i = SIN(i/100)
QuickCos.i = COS(i/100)
if ((i//23) == 0) then SetWindowTitle '"' || "Setting up rotation tables... " || 628-i || '"'
end
SetWindowTitle '"' || "Whee! 3D!" || '"'
Do Forever
Call Rotate
Q2 = (Q2 + 8) // 628
/* Q1 = (Q1 + 12) // 628 */
Q3 = (Q3 + 16) // 628
If Dist > 600 Then Do
Dist = Dist - 160
End
End
Rotate:
Do Cord = 1 TO RealCordNum
XPP2 = XPP.Cord
YPP2 = YPP.Cord
ZPP2 = ZPP.Cord * QuickCos.Q2 - YPP2 * QuickSin.Q2
YPP2 = YPP2 * QuickCos.Q2 + ZPP.Cord * QuickSin.Q2
XPP3 = XPP2 * QuickCos.Q3 - ZPP2 * QuickSin.Q3
ZPP2 = ZPP2 * QuickCos.Q3 + XPP2 * QuickSin.Q3
PE = 128000 / (Dist + ZPP2)
PSXOld.Cord = PSX.Cord
PSYOld.Cord = PSY.Cord
PSX.Cord = Trunc((XPP3 * PE) / 256 + XG)
PSY.Cord = Trunc((YPP2 * PE) / 256 + YG)
End
Do Lin = 1 TO RealLineNum
TL1 = L1.Lin
TL2 = L2.Lin
SetFPen 0
Line PSXOld.TL1 PSYOld.TL1 PSXOld.TL2 PSYOld.TL2
SetFPen 1
Line PSX.TL1 PSY.TL1 PSX.TL2 PSY.TL2
End
Do L = 1 TO RealCordNum
PSXOld.L = PSX.L
PSYOld.L = PSY.L
End
Return
Cube:
XPP.1 = -60
YPP.1 = -60
ZPP.1 = 60
XPP.2 = -60
YPP.2 = 60
ZPP.2 = 60
XPP.3 = 60
YPP.3 = 60
ZPP.3 = 60
XPP.4 = 60
YPP.4 = -60
ZPP.4 = 60
XPP.5 = -60
YPP.5 = -60
ZPP.5 = -60
XPP.6 = -60
YPP.6 = 60
ZPP.6 = -60
XPP.7 = 60
YPP.7 = 60
ZPP.7 = -60
XPP.8 = 60
YPP.8 = -60
ZPP.8 = -60
L1.1 = 1
L2.1 = 2
L1.2 = 2
L2.2 = 3
L1.3 = 3
L2.3 = 4
L1.4 = 4
L2.4 = 1
L1.5 = 5
L2.5 = 6
L1.6 = 6
L2.6 = 7
L1.7 = 7
L2.7 = 8
L1.8 = 8
L2.8 = 5
L1.9 = 1
L2.9 = 5
L1.10 = 2
L2.10 = 6
L1.11 = 3
L2.11 = 7
L1.12 = 4
L2.12 = 8
RealCordNum = 8
RealLineNum = 12
Return
Ball:
XPP.1 = 0
YPP.1 = 0
ZPP.1 = -30
XPP.2 = 0
YPP.2 = -20
ZPP.2 = -25
XPP.3 = 14
YPP.3 = -15
ZPP.3 = -25
XPP.4 = 20
YPP.4 = 0
ZPP.4 = -25
XPP.5 = 14
YPP.5 = 14
ZPP.5 = -25
XPP.6 = -1
YPP.6 = 20
ZPP.6 = -25
XPP.7 = -15
YPP.7 = 14
ZPP.7 = -25
XPP.8 = -20
YPP.8 = -1
ZPP.8 = -25
XPP.9 = -15
YPP.9 = -15
ZPP.9 = -25
XPP.10 = 0
YPP.10 = -40
ZPP.10 = -15
XPP.11 = 28
YPP.11 = -29
ZPP.11 = -15
XPP.12 = 40
YPP.12 = 0
ZPP.12 = -15
XPP.13 = 28
YPP.13 = 28
ZPP.13 = -15
XPP.14 = -1
YPP.14 = 40
ZPP.14 = -15
XPP.15 = -29
YPP.15 = 28
ZPP.15 = -15
XPP.16 = -40
YPP.16 = -1
ZPP.16 = -15
XPP.17 = -29
YPP.17 = -29
ZPP.17 = -15
XPP.18 = 0
YPP.18 = -60
ZPP.18 = 0
XPP.19 = 42
YPP.19 = -43
ZPP.19 = 0
XPP.20 = 60
YPP.20 = 0
ZPP.20 = 0
XPP.21 = 42
YPP.21 = 42
ZPP.21 = 0
XPP.22 = -1
YPP.22 = 60
ZPP.22 = 0
XPP.23 = -43
YPP.23 = 42
ZPP.23 = 0
XPP.24 = -60
YPP.24 = -1
ZPP.24 = 0
XPP.25 = -43
YPP.25 = -43
ZPP.25 = 0
XPP.26 = 0
YPP.26 = -40
ZPP.26 = 15
XPP.27 = 28
YPP.27 = -29
ZPP.27 = 15
XPP.28 = 40
YPP.28 = 0
ZPP.28 = 15
XPP.29 = 28
YPP.29 = 28
ZPP.29 = 15
XPP.30 = -1
YPP.30 = 40
ZPP.30 = 15
XPP.31 = -29
YPP.31 = 28
ZPP.31 = 15
XPP.32 = -40
YPP.32 = -1
ZPP.32 = 15
XPP.33 = -29
YPP.33 = -29
ZPP.33 = 15
XPP.34 = 0
YPP.34 = -20
ZPP.34 = 25
XPP.35 = 14
YPP.35 = -15
ZPP.35 = 25
XPP.36 = 20
YPP.36 = 0
ZPP.36 = 25
XPP.37 = 14
YPP.37 = 14
ZPP.37 = 25
XPP.38 = -1
YPP.38 = 20
ZPP.38 = 25
XPP.39 = -15
YPP.39 = 14
ZPP.39 = 25
XPP.40 = -20
YPP.40 = -1
ZPP.40 = 25
XPP.41 = -15
YPP.41 = -15
ZPP.41 = 25
XPP.42 = 0
YPP.42 = 0
ZPP.42 = 30
L1.1 = 2
L2.1 = 3
L1.2 = 3
L2.2 = 4
L1.3 = 4
L2.3 = 5
L1.4 = 5
L2.4 = 6
L1.5 = 6
L2.5 = 7
L1.6 = 7
L2.6 = 8
L1.7 = 8
L2.7 = 9
L1.8 = 9
L2.8 = 2
L1.9 = 1
L2.9 = 2
L1.10 = 1
L2.10 = 3
L1.11 = 1
L2.11 = 4
L1.12 = 1
L2.12 = 5
L1.13 = 1
L2.13 = 6
L1.14 = 1
L2.14 = 7
L1.15 = 1
L2.15 = 8
L1.16 = 1
L2.16 = 9
L1.17 = 10
L2.17 = 11
L1.18 = 11
L2.18 = 12
L1.19 = 12
L2.19 = 13
L1.20 = 13
L2.20 = 14
L1.21 = 14
L2.21 = 15
L1.22 = 15
L2.22 = 16
L1.23 = 16
L2.23 = 17
L1.24 = 17
L2.24 = 10
L1.25 = 2
L2.25 = 10
L1.26 = 3
L2.26 = 11
L1.27 = 4
L2.27 = 12
L1.28 = 5
L2.28 = 13
L1.29 = 6
L2.29 = 14
L1.30 = 7
L2.30 = 15
L1.31 = 8
L2.31 = 16
L1.32 = 9
L2.32 = 17
L1.33 = 18
L2.33 = 19
L1.34 = 19
L2.34 = 20
L1.35 = 20
L2.35 = 21
L1.36 = 21
L2.36 = 22
L1.37 = 22
L2.37 = 23
L1.38 = 23
L2.38 = 24
L1.39 = 24
L2.39 = 25
L1.40 = 25
L2.40 = 18
L1.41 = 10
L2.41 = 18
L1.42 = 11
L2.42 = 19
L1.43 = 12
L2.43 = 20
L1.44 = 13
L2.44 = 21
L1.45 = 14
L2.45 = 22
L1.46 = 15
L2.46 = 23
L1.47 = 16
L2.47 = 24
L1.48 = 17
L2.48 = 25
L1.49 = 26
L2.49 = 27
L1.50 = 27
L2.50 = 28
L1.51 = 28
L2.51 = 29
L1.52 = 29
L2.52 = 30
L1.53 = 30
L2.53 = 31
L1.54 = 31
L2.54 = 32
L1.55 = 32
L2.55 = 33
L1.56 = 33
L2.56 = 26
L1.57 = 26
L2.57 = 18
L1.58 = 27
L2.58 = 19
L1.59 = 28
L2.59 = 20
L1.60 = 29
L2.60 = 21
L1.61 = 30
L2.61 = 22
L1.62 = 31
L2.62 = 23
L1.63 = 32
L2.63 = 24
L1.64 = 33
L2.64 = 25
L1.65 = 34
L2.65 = 35
L1.66 = 35
L2.66 = 36
L1.67 = 36
L2.67 = 37
L1.68 = 37
L2.68 = 38
L1.69 = 38
L2.69 = 39
L1.70 = 39
L2.70 = 40
L1.71 = 40
L2.71 = 41
L1.72 = 41
L2.72 = 34
L1.73 = 34
L2.73 = 26
L1.74 = 35
L2.74 = 27
L1.75 = 36
L2.75 = 28
L1.76 = 37
L2.76 = 29
L1.77 = 38
L2.77 = 30
L1.78 = 39
L2.78 = 31
L1.79 = 40
L2.79 = 32
L1.80 = 41
L2.80 = 33
L1.81 = 34
L2.81 = 42
L1.82 = 35
L2.82 = 42
L1.83 = 36
L2.83 = 42
L1.84 = 37
L2.84 = 42
L1.85 = 38
L2.85 = 42
L1.86 = 39
L2.86 = 42
L1.87 = 40
L2.87 = 42
L1.88 = 41
L2.88 = 42
RealCordNum = 42
RealLineNum = 88
Return